package cn.openread.starter.utils;

import cn.openread.starter.utils.sms.MengWangSmsServiceImpl;
import cn.openread.starter.utils.sms.SmsService;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 提供发送短信服务
 *
 * @author simon
 * @create 2018-09-07 下午5:23
 **/
@Slf4j
@NoArgsConstructor
public class SmsStarter {
    private static volatile SmsService instance = null;

    /**
     * 获取支持腾讯云的实例
     */
    public SmsService getMengWangInstance() {
        return this.getInstance(SmsStaterEnum.MengWang);
    }

    private SmsService getInstance(SmsStaterEnum ossStaterEnum) {
        switch (ossStaterEnum) {
            case MengWang:
                if (instance == null) {
                    synchronized (SmsStarter.class) {
                        if (instance == null) {
                            instance = new MengWangSmsServiceImpl();
                        }
                    }
                }
                break;
        }
        return instance;
    }

    public enum SmsStaterEnum {
        MengWang
    }
}
